<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<title>短信发送列表</title>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/extjs.jsp"%>
<%@include file="/common/meta.jsp"%>
</head>
<body>
<table align="center" width="790" style="border-bottom: 2px solid #99BBE8;">
  <tr>
    <td align="left" style="padding-left: 20px;">
	  	<a href="${ctx}/smssend/edit.do">
	  	  <img src="${ctx}/images/icons/send.png">&nbsp;发送短信</a>
	  	&nbsp;&nbsp;
	  	<a href="${ctx}/smssend/index.do" style="color: red; font-weight: bold;">
  		<img src="${ctx}/images/exticons/arrow-up.gif">&nbsp;短信列表</a>
  		&nbsp;&nbsp;&nbsp;
  		<!-- 
	  	<a href="${ctx}/statistics/statByPersonal.do">
  		<img src="${ctx}/images/icons/gra.gif">&nbsp;短信统计</a>
  		 -->
    </td>
  </tr>
</table>
<form action="index.do" method="post" target="">
<table align="center" width="790">
	<tr>
		<td> 
		&nbsp;&nbsp;接收人：<s:textfield name="model.receiverName" cssStyle="width: 80px"/>&nbsp;
				手机号：<s:textfield name="model.mobileNum" cssStyle="width: 80px"/>&nbsp;
				发送时间：<input type="text" name="startDate" style="width: 120px"
						value='<s:date name="startDate" format="yyyy-MM-dd HH:mm"/>'
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm'})"
						class="Wdate" />
						至
					<input type="text" name="endDate" style="width: 120px"
						value='<s:date name="endDate" format="yyyy-MM-dd HH:mm"/>'
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm'})"
						class="Wdate" />&nbsp;
				最新：<input type="checkbox" style="border: 0px;" name="model.isNew" value="1" <s:if test="model.isNew != null">checked="checked"</s:if>>&nbsp;&nbsp;
				&nbsp;&nbsp;<input type="submit" value="查询" class="button">
		</td>
		<!--  
		<td align="right">
		<table>
			<tr>
				<td><a href="#" onclick="remove()"><img src="${ctx}/images/icons/delete.gif" />删除</a></td>
			</tr>
		</table>
		</td>
		-->
	</tr>
</table>
</form>
<ec:table items="items" var="item" retrieveRowsCallback="limit" sortRowsCallback="limit" 
	action="index.do" 
	useAjax="false"
	doPreload="false" 
	pageSizeList="10,20,50" 
	editable="false"
	sortable="false" 
	rowsDisplayed="10" 
	generateScript="true"
	resizeColWidth="false" 
	classic="false" 
	width="789" 
	height="310px"
	minHeight="310"
	csvFileName="短信发送纪录.csv"
	toolbarContent="navigation|pagejump|pagesize|refresh|extend|status">
	<ec:row style="height: 30px;">
		<ec:column width="30" property="_s" title="No." value="${GLOBALROWCOUNT}" style="text-align:center"/>
		<ec:column width="90" property="mobileNum" title="电话号码"/>
		<ec:column width="90" property="receiverName" title="接收人"/>
		<ec:column width="340" property="content" title="内容"/>
		<ec:column width="110" property="sendTime" title="发送时间" cell="date" format="yyyy-MM-dd HH:mm"/>
		<ec:column width="70" property="_type" title="状态" style="text-align:center">
			<s:if test="#attr.item.isNew eq 1"><font color="red">未发</font></s:if>
			<s:if test="#attr.item.isNew eq 0"><font color="green">已发</font></s:if>
		</ec:column>
		<ec:column width="57" property="_option" title="操作" style="text-align:center">
			<a href="#" onClick="viewSmsInfo(${item.id})">查看</a>
		</ec:column>
	</ec:row>
</ec:table>
<!-- 查看短信内容 -->
<div id="smsWindow" class="x-hidden">
<div class="x-window-header">短信内容</div>
<div class="x-window-body">
	<table width="600">
	  <tr>
	    <td align="right" width="90" height="28"><font color="green">发送号码：</font></td>
		<td align="left" id="smsNum"></td>
	  </tr>
	  <tr>
	    <td align="right" width="90" height="28"><font color="green">接&nbsp;收&nbsp;人：</font></td>
		<td align="left" id="receiver"></td>
	  </tr>
	  <tr>
	    <td align="right" width="90" height="28"><font color="green">发送时间：</font></td>
		<td align="left" id="sendTime"></td>
	  </tr>
	  <tr>
	    <td align="right" width="90" height="28"><font color="green">短信内容：</font></td>
		<td align="left" id="smsContent" style="line-height: 20px;"></td>
	  </tr>
	</table>
 </div>
</div>
<!-- 查看短信内容 -->
<script type="text/javascript">
  var SmsWindow = new Ext.Window({
      el: 'smsWindow',
      width: 630,
      height: 320,
      layout : 'fit',
      closeAction:'hide',
      buttonAlign:'center',
      modal:'false',
      buttons:[
        {text:'关闭',
        	handler:function(){
        	SmsWindow.hide();
        }
      }]
  });
  function viewSmsInfo(smsId) {
	  $.ajax({
		     url: '${ctx}/smssend/viewSmsSendInfo.do',
		     type: 'post',
			 dataType: 'json',
			 data: {smsSendId : smsId},
			 success: function(rst, textStatus){
				 if(rst.mobileNum != null) {
					 document.getElementById("smsNum").innerHTML = rst.mobileNum;
				 }
				 if(rst.receiver != null) {
					 document.getElementById("receiver").innerHTML = rst.receiver;
				 }
				 if(rst.sendTime != null) {
					 document.getElementById("sendTime").innerHTML = rst.sendTime;
				 }
				 if(rst.content != null) {
					 document.getElementById("smsContent").innerHTML = rst.content;
				 }
				 SmsWindow.show();
			 }
  	  }); 
  }
</script>

<script type="text/javascript">
/**
 * 删除提交
 */
function remove(){
    var sels = document.getElementsByName("selectedItems");
    var checked = false;;
    for(i = 0; i < sels.length; i++) {
        if(sels[i].checked) {
           checked = true;
           break;
        }
    } 
    if(!checked) {
    	Ext.MessageBox.show({
            title:'提示',
            minWidth:260,
            msg:'<div style=\'width:180\';><br/>请选择要删除的短信！</div>',
            buttons:Ext.MessageBox.OK,
            icon:Ext.MessageBox.INFO
       });
       return;
    }
	Ext.MessageBox.confirm('提示','确定要删除所选择的短信吗？删除后不能恢复！', function(btn){
        if (btn == 'yes') {
        	var from = document.getElementById("ec");
    		from.target="_self";
    		from.action="remove.do";
    		from.submit();
        }
    });
}

</script>
</body>
</html>